package dbops

import "log"

/* 创建一个简要彻底删除的表 video_del_rec  */

// ReadVideoDelRecord 批量对数据
func ReadVideoDelRecord(count int) ([]string, error) {
	stmt, err := dbConn.Prepare("SELECT video_id FROM video_del_rec LIMIT ?")
	var ids []string
	if err != nil {
		log.Printf("dbConn error: %v", err)
		return ids, err
	}
	rows, err := stmt.Query(count)
	if err != nil {
		log.Printf("Query Del tables err: %v", err)
		return ids, err
	}
	for rows.Next() {
		var id string
		if err := rows.Scan(&id); err != nil {
			log.Printf("Scan id error: %v", err)
			return ids, err
		}
		ids = append(ids, id)
	}
	defer stmt.Close()
	return ids, nil
}

// DelVideoRecord 删除
func DelVideoRecord(vid string) error {
	stmt, err := dbConn.Prepare("DELETE FROM video_del_rec WHERE video_id = ?")
	if err != nil {
		return err
	}
	_, err = stmt.Exec(vid)
	if err != nil {
		log.Printf("del DelVideoRecord err: %v", err)
		return err
	}
	defer stmt.Close()
	return nil
}
